//客服回信
Vue.component('customer_reply', {
	template:'<div class="service">\
					<div class="one_news my_flex my_flex_col" v-for="(item,index) in notices">\
						<div class="my_flex my_flex_between">\
							<span class="blod">{{item.Title}}</span>\
							<span class="time">{{item.CreateTimeText}}</span>\
						</div>\
						<div>\
							<span v-if="item.Content.length<40" class="two_col cursor active">{{item.Content}}</span>\
							<span v-else class="two_col cursor" @click="slideDown_up($event,\'two_col\')">{{item.Content}}</span>\
						</div>\
					</div>\
					<change-page :current_page="page.pageIndex" :page_size="page.pageSize" :page_total="page.pageTotal" @page-change="getServiceMessages"></change-page>\
				</div>',
	data: function() {
		return {
			url: {
				getServiceMessages: '/api/SiteMessage/GetServiceMessages',
			},
			notices: [],
			page: {
				pageIndex: 1,
				pageSize: 100,
				pageTotal: 0
			}
		}
	},
	mounted: function() {
		this.getServiceMessages(this.page.pageIndex, this.page.pageSize);
	},
	methods: {
		//获取帖子
		getServiceMessages: function(curPage, pageSize) {
			var that = this;
			var data = {
				PageIndex: curPage,
				PageSize: pageSize
			};
			globalData.ajaxPost(this.url.getServiceMessages, data, function(res) {
				var d = res.data;
				d = globalData.utils.notNullDefaulst(d,[]);
				globalData.utils.page(that, curPage, res.count);
				that.notices = d;
			})
		},
		slideDown_up: function(ev, targetClass) {
			var dom = $(ev.target)
			var targetDom = globalData.utils.get_target_dom(dom, targetClass)
			if(targetDom.hasClass('active')) {
				targetDom.removeClass('active')
			} else {
				targetDom.addClass('active')
			}
		},
	}
});